//
//  ZCTagButton.m
//  百思不得姐
//
//  Created by Ning Xie on 16/9/4.
//  Copyright © 2016年 zhangchong. All rights reserved.
//

#import "ZCTagButton.h"

@implementation ZCTagButton

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        [self setImage:[UIImage imageNamed:@"chose_tag_close_icon"] forState:UIControlStateNormal];
        self.backgroundColor = [UIColor blueColor];
        [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        self.adjustsImageWhenHighlighted = NO;
        
    }
    return self;
}

-(void)setTitle:(NSString *)title forState:(UIControlState)state{
    [super setTitle:title forState:state];
    
    [self sizeToFit];
    self.width += 5;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.titleLabel.x = 0;
    self.imageView.x = self.titleLabel.width + 5;
    
}


@end
